<%--
SYSTEM NAME 	: 기술적보호조치표준서비스
PROGRAM ID 		: pesFiledTestLst.jsp
PROGRAM NAME 	: 필드 평가 관리 
AUTHOR 			: 강평희
CREAT DATE 		: 2011-11-18
MODIFY DATE		: 
DESCRIPTION 	: 필드 평가 관리 화면
--%>
<%@ page language="java"
	import="java.sql.*,javax.sql.*,java.util.*,java.io.*,javax.naming.*"
	pageEncoding="UTF-8" %>
<%@ page import="com.markany.beans.util.*"%>
<%@ page import="com.markany.beans.property.*"%>
<%@ page import="com.markany.beans.src.MasterDao"%>
<%@ page import="org.apache.log4j.Logger"%>
<%@ page import="com.lsware.utils.UtilConstants"%>
<%! private Logger logger = Logger.getLogger(this.getClass().getName());
%>
<%
	//서버패스 잡기
	String ctxPath = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + ctxPath + "/ctis_mng";
	
	
	String PAGE = "pesFiledTestLst";
	String DIR = "pes";
	String PAGE_NAME = "필드 평가 관리";
	
%>
<%@ include file="/jsp/common/ctis_sessinc.jsp" %>
<jsp:useBean id="bean" class="com.markany.beans.util.PageBean" scope="page" />
<jsp:setProperty name="bean" property="*" />
<jsp:setProperty name="bean" property="intPageLine" value="10" />
<%
	String biznm = hp.getString("biznm","");
	String ospNm = hp.getString("ospname","");
	String SREG_DATE = hp.getString("SREG_DATE","");
	String EREG_DATE = hp.getString("EREG_DATE","");
	String ospbiznm = hp.getString("ospbiznm","");
	String pynval = hp.getString("pynval","");
	
	String sqlbiznm = "";
	String sqlospBiznm = "";
	String searchSql = "";
	String pynvalSql = "";
	
	if( !SREG_DATE.equals("") && !EREG_DATE.equals("")){
		searchSql = " AND O.REG_DATE >= TO_DATE('"+ SREG_DATE +" 00:00:00','YYYY-MM-DD HH24:MI:SS') \nAND O.REG_DATE < TO_DATE('"+ EREG_DATE +" 00:00:00','YYYY-MM-DD HH24:MI:SS')+1 \n" ;
	}
	
	if( SREG_DATE.equals("") && !EREG_DATE.equals("") ){
		searchSql = " AND O.REG_DATE < TO_DATE('"+ EREG_DATE +" 00:00:00','YYYY-MM-DD HH24:MI:SS')+1 \n" ;
	}
	
	if( ! biznm.equals("") ){
		sqlbiznm = " AND A.BIZ_NM LIKE '%' || '"+biznm+"' || '%' \n"; 	
	}
	
	if( ! ospNm.equals("") ){
		sqlospBiznm = " AND O.OSP_NAME LIKE '%' || '"+ospNm+"' || '%' \n"; 		
	}
	
	if( !pynval.equals("")){
		pynvalSql = " AND O.PASS_YN = '"+ pynval +"' \n";
	}
	
    String sql = "";
    MasterDao dao = null;
	Vector list = null;
	int totalCnt = 0;

	try{
		dao = new MasterDao();
		sql = "";
		sql += "SELECT  COUNT(*) \n";
		sql += " FROM TAB_TEST_1 A INNER JOIN PES_RESULT B ON A.RECEIPT_NO = B.RECEIPT_NO \n";
		sql += "  INNER JOIN PES_FIELD_TEST_OSP O ON B.RECEIPT_NO = O.RECEIPT_NO AND B.CONT_GB = O.CONT_GB AND A.TEST_GB = 'FT'";
		if( ! sqlbiznm.equals("") ) sql += sqlbiznm;
		if( ! sqlospBiznm.equals("") ) sql += sqlospBiznm;
		if( ! searchSql.equals("") ) sql += searchSql;
		if( ! pynvalSql.equals("") ) sql += pynvalSql;
		dao.setCommand(sql);
		
		totalCnt = dao.getTotalRowNoClose();
		
		dao.close();
		bean.setIntTotalRow(totalCnt);
		
		
		dao = new MasterDao();
		sql = "";
		sql += " SELECT * \n" ;
		sql += " FROM ( \n";
		sql += " SELECT RESULT_TABLE.*\n";
		sql += " FROM ( \n";
		sql += " SELECT LIST_TABLE.* ,  ROWNUM RNO\n";
		sql += " FROM (\n";
		sql += "SELECT A.RECEIPT_NO, B.CONT_GB, A.BIZ_NM AS REBIZNM, O.BIZ_NM AS BIZNM, O.BIZ_NM AS OPSBIZNM, O.OSP_NAME, O.HOMEPAGE, O.UPLOAD_ID, O.UPLOAD_PASS, O.PASS_YN \n";
		sql += " FROM TAB_TEST_1 A INNER JOIN PES_RESULT B ON A.RECEIPT_NO = B.RECEIPT_NO \n";
		sql += "  INNER JOIN PES_FIELD_TEST_OSP O ON B.RECEIPT_NO = O.RECEIPT_NO AND B.CONT_GB = O.CONT_GB AND A.TEST_GB = 'FT'";
		if( ! sqlbiznm.equals("") ) sql += sqlbiznm;
		if( ! sqlospBiznm.equals("") ) sql += sqlospBiznm;
		if( ! searchSql.equals("") ) sql += searchSql;
		if( ! pynvalSql.equals("") ) sql += pynvalSql;
		sql += "  ORDER BY O.REG_DATE DESC";
		sql += "  ) LIST_TABLE  ) RESULT_TABLE WHERE RNO<= ?  ) LIST WHERE RNO BETWEEN ? AND ?";
		dao.setCommand(sql);
	
		int arg = 1; 
		
		dao.setInt(arg++, (bean.getIntCurrentPage() * bean.getIntPageLine()));
		dao.setInt(arg++, (bean.getIntCurrentPage() - 1) * bean.getIntPageLine() + 1);
		dao.setInt(arg++, (bean.getIntCurrentPage() * bean.getIntPageLine()));	
		
		list = dao.getResultHashtableNoClose();

		
	} catch (Exception e) {
		logger.error(PAGE + " Exception e.toString()      : " + e.toString());
		logger.error(PAGE + " Exception e.getMessage()    : " + e.getMessage());
		logger.error(PAGE + " Exception strQuery  : \n" + sql);
	%>
	<SCRIPT LANGUAGE="JavaScript">
	<!--
		alert(' [<%=PAGE%>] : <%=e.toString().replace("\n","")%>')
	//-->
	</SCRIPT>
	<%
	} finally {
		dao.close();
	}

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title>기술적보호조치표준서비스</title>
  <META http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <link rel="stylesheet" type="text/css" href="../css/common.css"></link>
  <link rel="stylesheet" type="text/css" href="../css/contents.css"></link>
  <link rel="stylesheet" type="text/css" href="../css/new.css"></link>
  <link rel="stylesheet" type="text/css" href="../css/tcal.css" />
  <script type="text/javascript" src="../js/popupcalendar.js"></script>
  <script type="text/javascript" src="../js/jquery.js" ></script>
  <script type="text/javascript" src="js/gnb.js"></script>
  <script language="JavaScript" src="../js/common.js" ></script>
  <script type="text/javascript" src="../js/tcal.js"></script>
  <SCRIPT LANGUAGE="JavaScript">
<!--
	var f = document.all;

	function search() {
		
		var frm = document.form;
		
		var pyn = frm.passYN;
		
		var conVal = "";
	    for(var t=0;t<pyn.length; t++){
	    	
	    	if( pyn[t].checked ) conVal = pyn[t].value;
	    }
		
	    frm.pynval.value = conVal;
	    
	    var sd = frm.SREG_DATE.value;
	    var ed = frm.EREG_DATE.value;
	    
	    if( sd != "" && ed == "" ){
	    	
	    	alert("신청기간의 종료일자를 입력해 주세요.");
	    	frm.EREG_DATE.focus();
	    	return;
	    }
	    
	    if( sd != "" && ed != "" ){
	    	
	    	var start_dates = sd.split("-");
		    var end_dates = ed.split("-");
		  
		   var date1 = new Date(start_dates[0],start_dates[1],start_dates[2]).valueOf();
		   var date2 = new Date(end_dates[0],end_dates[1],end_dates[2]).valueOf();
		  
		  if( (date2 - date1) < 0 ){
		   alert( "마지막날짜는 시작날짜 뒤로 선택하십시오.");
		   return;
		  }
		  
		}  

		frm.action = "pesFieldTestLst.jsp";
		frm.submit();
	}
	
	function Page(page) {
		document.form.intCurrentPage.value = page;
		document.form.action = "pesFieldTestLst.jsp";
		document.form.submit();
	}

	function goShowForm(r,g,t,typ){
		
		document.form.RECEIPT_NO.value = r;
		document.form.CONT_GB.value = g;
		document.form.OSPNAME.value = t;
		document.form.TYPE.value = typ;
		document.form.action = "pesFieldTestForm.jsp";
		document.form.submit();
		
		
	}
	
	

//-->
</SCRIPT>
  <style type="text/css">
        <!--
        body {
        font-family: Arial, Helvetica, sans-serif;
        font-size: 12px;
        }
        .text{
        font-family: Arial, Helvetica, sans-serif;
        font-size: 12px;
        }
        -->
 </style>
 </head>

 <body>
<%@ include file="/ctis_mng/common/menu.jsp"%>
<div id="contents">
<form method = "post" name = "form">
<input type="hidden" name="intCurrentPage" value="<%=bean.getIntCurrentPage()%>" />
<input type="hidden" name="pynval" value="" />
<input type="hidden" name="RECEIPT_NO" value=""/>
<input type="hidden" name="CONT_GB" value=""/>
<input type="hidden" name="OSPNAME" value=""/>
<input type="hidden" name="TYPE" value=""/>
		<!-- right -->
		
			<table class="checkTable last">
				<tr>
					<th width="100" class="center">기술업체명</th>
					<td>
						<input type="text" id="biznm" name="biznm" value="<%=biznm %>" class="img w170"/>	
					</td>
				    <th width="100" class="center">OSP 명</th>
					<td colspan="1">
						<input type="text" id="ospname" name="ospname" value="<%=ospNm %>" class="img w92" />
					</td>
				</tr>
				<tr>
					<th width="100"  class="center">신청기간</th>
					<td class="p10" colspan="3" width="300" >
						<input type="text" name="SREG_DATE" value="<%=SREG_DATE %>" class="tcal" />&#160;&#160;&#160;~&#160;&#160;&#160;
						<input type="text" name="EREG_DATE" value="<%=EREG_DATE %>" class="tcal"  />
					</td>
				</tr>
				<tr>
					<th width="100" class="center">평가결과 </th>
					<td width="200" colspan="3">
						<input type="radio" name="passYN" value="" <%if(pynval.equals("")){ %> checked="checked" <%} %> />전체&nbsp;
						<input type="radio" name="passYN" value="Y" <%if(pynval.equals("Y")){ %> checked="checked" <%} %>/>성공&nbsp;
						<input type="radio" name="passYN" value="N" <%if(pynval.equals("N")){ %> checked="checked" <%} %>/>실패&nbsp;
						<input type="radio" name="passYN" value="S" <%if(pynval.equals("S")){ %> checked="checked" <%} %>/>신청&nbsp;
						<input type="radio" name="passYN" value="A" <%if(pynval.equals("A")){ %> checked="checked" <%} %>/>접수&nbsp;
						<input type="radio" name="passYN" value="R" <%if(pynval.equals("R")){ %> checked="checked" <%} %>/>반려&nbsp;
					</td>
				</tr>
		    </table>
		    <div class="buttonC">
				<a href="javascript:search();" onfocus="this.blur();"><img src="../images/btn_apply.gif" width="55" height="25" alt="조회" align="absmiddle" /></a>
        	</div>
        	
        <div class="dashLine"></div>
</form>	
<%if(list.size()>0){ %>
        <h3>
        	<img src="../images/title_searchMusicCon.gif" width="67" height="15" alt="검색결과" />
        </h3>
		<p id="searchWord" class="main_text_1">
			<span class="word"><%=totalCnt%> 건</span>이 검색되었습니다.
		</p>		
<table class="bgTable2">

	<tr>
		<th width="40">순번</th>
		<th width="100">신청업체</th>
		<th width="150"><p><span>|</span>OSP 명</p></th>
		<th width="150"><p><span>|</span>홈페이지</p></th>
		<th width="100"><p><span>|</span>회사명</p></th>
		<th width="200"><p><span>|</span>접속계정</p></th>
		<th width="50"><p><span>|</span>통과</BR>여부</p></th>
<%--		<th width="120"><p><span>|</span>결과조회</p></th>--%>
	</tr>
<% 
	
	String bizNm = "";
	String ospbizNm = "";
	String ospname = "";
	String homepage = "";
	String upip = "";
	String uppass = "";
	String passYn = "";
	String receipt_no = "";
	String cont_gb = "";

	
	
	
	int bno = 0;
    int CNum = bean.getIntCurrentPage() ;
    
	for (int i=0 ;i<list.size();i++){
		String pyn = "";
		String ipNpass = "";
		bno = (totalCnt- (CNum-1)*10) - i;
		bizNm		= ((Hashtable) list.elementAt(i)).get("REBIZNM")+"";
		ospbizNm	= ((Hashtable) list.elementAt(i)).get("BIZNM")+"";
		ospname		= ((Hashtable) list.elementAt(i)).get("OSP_NAME")+"";
		homepage	= ((Hashtable) list.elementAt(i)).get("HOMEPAGE")+"";
		upip		= ((Hashtable) list.elementAt(i)).get("UPLOAD_ID")+"";
		uppass		= ((Hashtable) list.elementAt(i)).get("UPLOAD_PASS")+"";
		passYn		= ((Hashtable) list.elementAt(i)).get("PASS_YN")+"";
		receipt_no	= ((Hashtable) list.elementAt(i)).get("RECEIPT_NO")+"";
		cont_gb		= ((Hashtable) list.elementAt(i)).get("CONT_GB")+"";
		
		
		if( passYn.equals("Y") ){
			pyn = "<font color='red'>성공</font>";
		} else if( passYn.equals("S") ){
			pyn = "<font color='blue'>신청</font>";
		} else if( passYn.equals("A") ){
			pyn = "<font color='blue'>접수</font>";
		} else if( passYn.equals("R") ){
			pyn = "<font color='blue'>반려</font>";
		} else if( passYn.equals("N") ){
			pyn = "<font color='blue'>실패</font>";
		} else{
			
		}
	
		if( ! upip.equals("") && ! uppass.equals("")  ){
			
			ipNpass = upip + " / " + uppass; 
			
		}
	
%>		
	<tr>
		<td><%=bno %></td>
		<td>
			<a href="javascript:goShowForm('<%=receipt_no %>','<%=cont_gb %>','<%=ospname %>','show');" ><%=bizNm %></a>
		</td>
		<td>
			<a href="javascript:goShowForm('<%=receipt_no %>','<%=cont_gb %>','<%=ospname %>','in');" ><%=ospname %></a>
		</td>
		<td>
			<%=homepage %>
		</td>
		<td>
			<%=ospbizNm %>
		</td>
		<td>
			<%=ipNpass %>
		</td>
		<td>
			<%=pyn %>
		</td>
<%--		<td>--%>
<%--			<a href="javascript:goShowForm('<%=receipt_no %>','<%=cont_gb %>','<%=ospname %>','in');" ><span style="font-size: 10px; font-weight:bold; color:#696969;">[로그등록/결과조회]</span></a>--%>
<%--		</td>--%>
	</tr>	
<%} %>	
</table>
<div class="paging">
			<% 
if(list.size()>0){ 
	int iTemp=0;
	int intCurrentPage  = bean.getIntCurrentPage() ;
	int intTotalPage    = bean.getIntTotalPage() ;
	int intPageNum      = bean.getIntPageNum() ;

	int intStartPage    = ((int)Math.ceil((double)intCurrentPage/(double)intPageNum) -1 ) * intPageNum +1 ;
%>
	<% if (intStartPage>10) { %>
		<a href="JavaScript:Page('<%= intStartPage-intPageNum %>')"><img src="../images/common/page_llArrow.gif" width="11" height="11" alt="맨 앞으로" /></a>&nbsp;
	<%	}else{	%>
		<img src="../images/common/page_llArrow.gif" width="11" height="11" alt="맨 앞으로" />&nbsp;
	<%  }  %>

	<% if (intCurrentPage>1) { %>
		<a href="JavaScript:Page('<%= intCurrentPage-1 %>')"><img src="../images/common/page_lArrow.gif" width="11" height="11" alt="이전" /></a>&nbsp;
	<%	}else{	%>
		<img src="../images/common/page_lArrow.gif" width="11" height="11" alt="이전" />&nbsp;
	<%  }  %>

	<% 
	  for (int i=intStartPage; i<intStartPage + intPageNum ; i++) { 
		iTemp=i;
		if (i<=intTotalPage) {
			if (i !=intCurrentPage) {
	%>
		<a href="JavaScript:Page('<%= i %>')"><%= i %></a><%=(i<intTotalPage)?"<span>|</span>":""%>
	<%		} else {	%>
		<span class="current"><%= i %></span><%=(i<intTotalPage)?"<span>|</span>":""%>
	<%		}	
		} else	{
			break;
		}	
 	  }
	%>
	<%	if (intCurrentPage < intTotalPage) { %>
		&nbsp;<a href="JavaScript:Page('<%= intCurrentPage+1 %>')"><img src="../images/common/page_rArrow.gif" width="11" height="11" alt="다음" /></a>
	<%	}else{	%>
		&nbsp;<img src="../images/common/page_rArrow.gif" width="11" height="11" alt="다음" />
	<%  }	%>
	
	<%	if (iTemp+1<= intTotalPage) { %>
		&nbsp;<a href="JavaScript:Page('<%= iTemp+1 %>')"><img src="../images/common/page_rrArrow.gif" width="11" height="11" alt="맨 뒤로" /></a>
	<%	}else{	%>
		&nbsp;<img src="../images/common/page_rrArrow.gif" width="11" height="11" alt="맨 뒤로" />
	<%  }	%>
<%}%>
		</div>	
		<%}else{ %>
<table align="center" >
	<tr>
		<td colspan="6"  class="word">데이터가 없습니다.</td>
	</tr>
</table>
<%} %>	

	
<table><tr><td>&nbsp;</td></tr></table>

</div>
	<!-- //content -->

	<!-- footer -->
	<div id="footer">
		<img src="../images/common/copyright.gif" width="253" height="12" alt="" />
	</div>
	<!-- //footer -->
  </body>
</html>

